package org.jw.testemunhopublico.util;

import java.text.MessageFormat;

import javax.inject.Inject;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.core.env.Environment;

@Configuration
@PropertySources({
	@PropertySource("classpath:META-INF/config.properties"),
	@PropertySource("classpath:META-INF/faces-messages.properties"),
	@PropertySource("classpath:META-INF/labels.properties"),
	@PropertySource("classpath:META-INF/messages.properties"),
	@PropertySource("classpath:META-INF/pages.properties")
})
public class PropertiesUtil {

	protected Environment env;
	
	public String getValue(String key){
		return env.getProperty(key);
	}
	
	public String getValue(String key, String... args){
		if (args != null)
			return MessageFormat.format(getValue(key), args);
		return getValue(key);
	}
	
	@Inject
	public void setEnvironment(Environment arg){
		this.env = arg;
	}
	
}
